package com.lw.extraceim.zxing;

import android.app.Activity;

import com.google.zxing.integration.android.IntentIntegrator;

public class ZxingUtiil {

    /**
     * 启动条形码扫描
     *
     * @param activity
     * @param captureActivity
     * @param prompt
     * @param requestCode
     */
    public static void  startQRScan(Activity activity, Class captureActivity,
                            String prompt, int requestCode) {
        IntentIntegrator intentIntegrator = new IntentIntegrator(activity);
        intentIntegrator.setCaptureActivity(captureActivity);
        intentIntegrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);
        intentIntegrator.setPrompt(prompt);

        //设置请求码
        intentIntegrator.setRequestCode(requestCode);
//        application.setScanActivityRequestCode(requestCode);
        intentIntegrator.setBeepEnabled(true);
        intentIntegrator.setBarcodeImageEnabled(true);
        intentIntegrator.initiateScan();
    }
}
